﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AvatarHelper;
using Avatar.Model;
using Avatar.MembershipService;

public partial class Company_ResumeSearch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
    }
    protected void btn_Search_Click(object sender, EventArgs e)
    {
        var _user = LoginManager.GetCurrentUser();
        if (_user != null)
        {
            using (var _adc = DBHelper.GetDataContext())
            {
                var _resume = _adc.Resume.Where(r => r.PersonalBasicInfo != null && r.JobIntention != null && (r.JobIntention.JobIntentionPosition.FirstOrDefault(j => j.PositionID == Position1.PositionID) != null)).OrderBy(r => r.UpdateDate);

                var _companyService = _adc.CompanyService.FirstOrDefault(c => c.Company == _user.UserName);
                if (_companyService != null)
                {
                    switch (_companyService.ServiceTypeID)
                    {
                        case 1:
                            gv_General.DataSource = _resume;
                            gv_General.DataBind();
                            break;
                        case 2:
                            gv_Vip.DataSource = _resume;
                            gv_Vip.DataBind();
                            break;
                        case 3:
                            gv_Vip.DataSource = _resume;
                            gv_Vip.DataBind();
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    gv_General.DataSource = _resume;
                    gv_General.DataBind();
                }
            }
        }
    }
    protected void btn_View_Vip(object sender, EventArgs e)
    {
        Button _btn = sender as Button;

        Page.RegisterClientScriptBlock("resume", "<script>window.open('resumeview.aspx?user=" + (string.IsNullOrEmpty(_btn.CommandArgument) ? string.Empty : _btn.CommandArgument) + "','_blank');</script>");
    }

}
